<template>
	<view>
		<n-loading></n-loading>
		<view class="devoteRankTop">
			<view class="devoteRankTopBj"></view>
			<view class="devoteRankTopCont">
				<u-avatar class="avatar" :src="avatar==null?src:avatar" size="64"></u-avatar>
				<view class="name">{{nickname==null?'暂无':nickname}}</view>
				<view class="sumup">
					<view class="item">
						<view class="tit">我的团队(人)</view>
						<view class="vals">{{count}}</view>
					</view>
					<view class="item">
						<view class="tit">团队收益(元)</view>
						<view class="vals">{{amount}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="teamBox" v-if="devoteListReady">
			<view class="nodata" v-if="devoteList.length==0">
				<image src="../../static/svgIcon/noIntegral.svg" mode=""></image>
				<view class="tips">暂无排名~</view>
			</view>
			<view class="teamList" v-for="(item,index) of devoteList" :key="index">
				<!-- item.userInfo.avatar -->
				<u-avatar :src="item.userInfo.avatar==null?src:item.userInfo.avatar" size="80"></u-avatar>
				<view class="right">
					<view class="memName">
						{{item.userInfo.nickname==null?'暂无':item.userInfo.nickname}}
						<text>团队{{item.user_son}}人</text>
					</view>
					<view class="bottom">
						<view class="fl">对我贡献<text>{{item.for_me}}</text></view>
						<view class="rt">他的收益<text>{{item.for_other}}</text></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				amount:null,
				count:null,
				avatar:null,
				nickname:null,
				devoteList:[],
				devoteListReady:null,
				teamNum:'',
				src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg'
			}
		},
		onLoad: function (option) {
			this.getDevoteList();
		},
		onPullDownRefresh() {
			this.devoteList = [];
			this.getDevoteList();
			setTimeout(function () {
				uni.stopPullDownRefresh();  //停止下拉刷新动画
			}, 2000);
		},
		methods: {
			getDevoteList(){
				this.apiget('/fun/member/contribution-ranking',{}).then(res =>{
					if(res.data.status == 200 ) {
						this.amount = res.data.data.amount;
						this.count = res.data.data.count;
						this.avatar = res.data.data.avatar;
						this.nickname = res.data.data.nickname;
						this.devoteList = res.data.data.team;
						this.devoteListReady = 1;
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.devoteRankTop{
		position: relative;
		padding: 40rpx 32rpx 32rpx;
		background-color: #F8F8FA;
		
		.devoteRankTopBj{
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 200rpx;
			background-color: #F3512D;
		}
		
		.devoteRankTopCont{
			position: relative;
			padding: 48rpx 0 32rpx;
			background: #FFFFFF;
			box-shadow: 0px 8rpx 16rpx rgba(0, 0, 0, 0.04);
			border-radius: 16rpx;
			
			.avatar{
				position: absolute;
				top:10rpx;
				left: 50%;
				margin: -32rpx;
			}
			
			.name{
				margin-bottom: 32rpx;
				text-align: center;
				font-size: 28rpx;
				line-height: 44rpx;
				color: #333333;
			}
			
			.sumup{
				display: flex;
				text-align: center;
				align-items: center;
				padding: 0 60rpx;
				
				.item{
					flex: 1;
					
					.tit{
						font-size: 24rpx;
						line-height: 40rpx;
						color: #666666;
					}
					
					.vals{
						font-weight: bold;
						font-size: 48rpx;
						line-height: 64rpx;
						color: #333333;
					}
				}
			}
		}
	}
	.teamList {
		display: flex;
		align-items: center;
		margin: 0 32rpx;
		padding: 24rpx 0;
		font-size: 32rpx;
		// border-bottom: 1rpx solid #EEEFF3;
	
	
		.u-avatar {
			margin-right: 32rpx;
		}
		
		.right{
			flex: auto;
			
			.memName{
				margin-bottom: 8rpx;
				font-size: 32rpx;
				line-height: 48rpx;
				color: #333;
				
				text{
					float: right;
					font-size: 28rpx;
				}
			}
				
			.bottom {
				color: #666666;
				font-size: 24rpx;
				line-height: 40rpx;
				
				text{
					margin-left: 8rpx;
					color: #F3512D;
				}
				
				.fl{
					float: left;
				}
				
				.rt{
					float: right;
				}
			}
		}

	}
</style>
